<?php

/**
 * 文章模块
 *
 * Created by PhpStorm.
 * User: evan
 * Date: 2016/12/13
 * Time: 上午11:47
 */
class Article extends MY_M_Controller
{
    /**
     * 文章列表
     */
    public function listing()
    {
    	$cid   = (int)$this->input->get('cid');
    	$page  = (int)$this->input->get('page');
    	$limit = (int)$this->input->get('limit');
    	
    	$this->load->service('article/service_article_base');
    	$data = $this->service_article_base->lists($cid, $page, $limit);
    	
    	$this->load->model('article/Model_article_cate','article_cate');
    	$article_cate = $this->article_cate->getById($cid);
    	
    	$data['article_cate'] = $article_cate;
    	
        $this->load->view('m/article/listing', $data);
    }


    /**
     * 文章详情
     */
    public function detail()
    {
    	$aid = intval($this->input->get('aid'));
    	
    	if(!$aid){
    		show_error('参数错误！', '500', '提示');
    	}
    	
    	$this->load->service('article/service_article_base');
    	$data = $this->service_article_base->item($aid);
    	
        $this->load->view('m/article/detail', $data);
    }


    /**
     * 微信新闻列表
     */
    public function weixin_list()
    {
    	$cid   = (int)$this->input->get('cid');
    	$page  = (int)$this->input->get('page');
    	$limit = (int)$this->input->get('limit');
    	
    	$cid = $cid ? $cid :10;
    	 
    	$this->load->service('article/service_article_base');
    	$data = $this->service_article_base->lists($cid, $page, $limit);
    	 
    	$this->load->model('article/Model_article_cate','article_cate');
    	$article_cate = $this->article_cate->lists(OFFSET, LIMIT, array('pid' => 9), true, 'sort asc');
    	 
    	$data['article_cate'] = $article_cate;
    	 
    	$this->load->view('m/article/weixin_list', $data);
    }


    /**
     * 微信新闻详情
     */
    public function weixin_detail()
    {
    	$aid = intval($this->input->get('aid'));
    	 
    	if(!$aid){
    		show_error('参数错误！', '500', '提示');
    	}
    	 
    	$this->load->service('article/service_article_base');
    	$data = $this->service_article_base->item($aid);
    	 
    	$this->load->view('m/article/weixin_detail', $data);
    }
}